<?xml version="1.0"?>
<OnTheFlyInstruction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <InstanceId>RSS/Atom C# Sample</InstanceId>
  <CustomAppConfig />
  <Tags>
    <string>Core</string>
  </Tags>
  <AdditionalAssemblies />
  <Code><![CDATA[using xSolon.Instructions;
 using System;
 using System.Data;
 using System.Linq;
using System.ServiceModel.Syndication;
using System.Xml;
using System.Net;
using System.Text;
using System.IO;
using xSolon.Instructions.DTO;
using System.Xml.Linq;
using Newtonsoft.Json;

namespace MyNamespace904
{
	public class Sample1 : AbstractInstruction
{
	
	public Sample1(){ Tags = new string[] {"Generated"};}

	public override void Run()
	{
		var reader = XmlReader.Create("http://feeds.andrewconnell.com/AndrewConnell");

		var feed = SyndicationFeed.Load(reader);

		using (var sw = new StringWriter())
		using (var xw = XmlWriter.Create(sw)) 
		{
			feed.SaveAsRss20(xw);
	
			//feed.SaveAsAtom10(xw);

			var doc = sw.ToString().GetXmlDocumentFromHTMLBody();

			var elem = doc.XSol_DocToElem();
			
			var nodes = elem.Descendants().Where(i => 
				i.Name.LocalName.Equals("pubdate", StringComparison.InvariantCultureIgnoreCase));
				
			nodes.ToList().ForEach(i =>{
				this.NotifyInformation(DateTime.Parse(i.Value).ToShortDateString());
			});
			
			this.NotifyInformation("Items # {0}",nodes.Count());
			
			Response = Newtonsoft.Json.JsonConvert.SerializeObject(doc);
//			Response = doc.Beautify();
		}

	}
	}
}]]></Code>
</OnTheFlyInstruction>